package com.wrial;
/*
 * @Author  Wrial
 * @Date Created in 10:14 2020/6/27
 * @Description
 */



public class Trial {
    public ListNode reverseList(ListNode head) {

        ListNode ans = new ListNode(0);
        ListNode p = head;


        while(p!=null){
            ListNode temp = ans.next;
            ans.next = p;
            ans.next.next = temp;
            p = p.next;
        }
        return ans;

    }

    public class ListNode {
        ListNode(int x) {
            val = x;
        }

        int val;

        ListNode next;
    }

}
